<style>
    .tab-float-box{
        display: none;
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,.3);
        z-index: 10000;
    }
    .tab-float-box .box{
        position: absolute;
        background-color: #fff;
        width: 350px;
        height: 135px;
        padding: 30px 20px 20px;
        left: 50%;
        top: 50%;
        margin-top: -120px;
        margin-left: -145px;
    }
    .tab-float-box .tit{
        float: left;
        height: 30px;
        line-height: 30px;
        padding-right: 20px;
    }
    .tab-float-box .in{
        float: left;
    }
    .tab-float-box .btn-box {
        clear: both;
        padding: 30px 40px 0 40px;
        text-align: right;
    }
    .tab-float-box .btn-box a{
        display: inline-block;
        padding: 4px 12px;
        text-align: center;
        border-radius: 2px;
        color: #fff;
        line-height: 20px;
        margin-left: 5px;
    }

    .tab-float-box .btn-box a.enter {
        background-color: #4285f4;
    }
    .tab-float-box .btn-box a.res {
        background-color: #f44336;
    }
</style>
<div class="btn-group">
    <a class='btn btn-primary'> <i class="fa"></i> <?php echo $title; ?> </a>
</div>

<?php include_once 'inc_modules_path.php'; ?>
<span>仲裁未处理数<?php echo $total?></span>
<span>悬赏介入未处理数<?php echo $total2?></span>
<?php include_once 'inc_ctype_index.php'; ?>
<?php
$info1 = $this->db->query("select id,title from boc_category where ctype=30 order by id desc")->result_array();
$info2 = $this->db->query("select id,title from boc_category where ctype=31")->result_array();
$info3 = $this->db->query("select id,title from boc_category where ctype=32")->result_array();
?>

<div class="clearfix"><p></p></div>
<?php if($this->cid==13){?>
<?php echo form_open(site_url('needs/index'),array('method'=>'get')); ?>
<input type='hidden' name='c' value='<?php echo $this->cid; ?>'>
发布人
<input type='text' name='uname' value='<?php if(isset($_GET['uname']) and $_GET['uname']){ echo $_GET['uname']; } ?>'>
悬赏分类
<select name="cate_id" style="margin-top: -9px;width: 150px;">
    <option value="0">全部</option>
    <?php foreach($info1 as $v1){?>
    <option value="<?php echo $v1['id'];?>" <?php if(isset($_GET['cate_id']) and $_GET['cate_id']==$v1['id']){echo 'selected';}?>><?php echo $v1['title'];?></option>
    <?php }?>
</select>
悬赏内容
<input type='text' name='intro' value='<?php if(isset($_GET['intro']) and $_GET['intro']){ echo $_GET['intro']; } ?>'>
悬赏状态
<select name="claim_status" style="margin-top: -9px;width: 150px;">
    <option value="-1" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==-1){echo 'selected';}?>>全部</option>
    <option value="0" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==0){echo 'selected';}?>>待支付</option>
    <option value="1" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==1){echo 'selected';}?>>认领中</option>
    <option value="2" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==2){echo 'selected';}?>>待指派</option>
    <option value="3" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==3){echo 'selected';}?>>待申请佣金</option>
    <option value="4" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==4){echo 'selected';}?>>确认并评价</option>
    <option value="5" <?php if(isset($_GET['claim_status']) and $_GET['claim_status']==5){echo 'selected';}?>>已完成</option>
</select>
仲裁状态
<select name="arbitrate" style="margin-top: -9px;width: 120px;">
    <option value="0">全部</option>
    <option value="1">待处理</option>
    <option value="2">已处理</option>
</select>
排序
<select name="choose_order" style="margin-top: -9px;width: 140px;">
    <option value="0" <?php if(isset($_GET['choose_order']) and $_GET['choose_order']==0){echo 'selected';}?>>发布时间倒序</option>
    <option value="1" <?php if(isset($_GET['choose_order']) and $_GET['choose_order']==1){echo 'selected';}?>>认领结束时间升序</option>
</select>
<input class='btn'  type='submit' value='查询' style="margin-top: -12px;">
<?php echo form_close(); ?>
<?php }elseif($this->cid==14){?>
<?php echo form_open(site_url('needs/index'),array('method'=>'get')); ?>
<input type='hidden' name='c' value='<?php echo $this->cid; ?>'>
发布人
<input type='text' name='uname' value='<?php if(isset($_GET['uname']) and $_GET['uname']){ echo $_GET['uname']; } ?>'>
活动分类
<select name="cate_id" style="margin-top: -9px;">
    <option value="0">全部</option>
    <?php foreach($info2 as $v2){?>
        <option value="<?php echo $v2['id'];?>"><?php echo $v2['title'];?></option>
    <?php }?>
</select>
<input class='btn'  type='submit' value='查询' style="margin-top: -12px;">
<?php echo form_close(); ?>
<?php }elseif($this->cid==15){?>
<?php echo form_open(site_url('needs/index'),array('method'=>'get')); ?>
<input type='hidden' name='c' value='<?php echo $this->cid; ?>'>
发布人
<input type='text' name='uname' value='<?php if(isset($_GET['uname']) and $_GET['uname']){ echo $_GET['uname']; } ?>'>
需求分类
<select name="cate_id" style="margin-top: -9px;">
    <option value="0">全部</option>
    <?php foreach($info3 as $v3){?>
        <option value="<?php echo $v3['id'];?>"><?php echo $v3['title'];?></option>
    <?php }?>
</select>
<input class='btn'  type='submit' value='查询' style="margin-top: -12px;">
<?php echo form_close(); ?>
<?php }?>

<div class="boxed">
	<div class="boxed-inner seamless">

<table class="table table-striped table-hover select-list">
	<thead>
		<tr>

            <?php if($this->cid==13 || $this->cid==14){?>
			<th class="width-small"><input id='selectbox-all' type="checkbox" > </th>
            <?php }?>
            <th>id</th>
			<th>发布人</th>
            <?php if($this->cid==13){?>
			<th>悬赏分类</th>
			<th>押金</th>
			<th>议价价格</th>
			<th>修改后价格</th>
			<th>悬赏内容</th>
			<th>发布时间</th>
			<th>认领人数</th>
			<th>认领结束时间</th>
			<th>浏览数</th>
			<th>悬赏状态</th>
			<th>发布方仲裁</th>
			<th>认领方仲裁</th>
            <?php }elseif($this->cid==14){?>
            <th>活动分类</th>
            <th>活动内容</th>
            <th>发布时间</th>
            <th>报名截止时间</th>
            <th>报名人数</th>
            <th>浏览数</th>
            <?php }elseif($this->cid==15){?>
            <th>需求分类</th>
            <th>需求内容</th>
            <th>发布时间</th>
            <?php }?>
            <?php if($this->cid==13 || $this->cid==14){?>
			<th class="span1">操作</th>
            <?php }?>
		</tr>
	</thead>
	<tbody class="sort-list">
        <?php $needs_status=array(0=>'待支付',1=>'认领中',2=>'待指派',3=>'待申领佣金',4=>'确认并评价',5=>'已完成',6=>'撤销',7=>'关闭',8=>'取消');?>
        <?php $arbitrate_status=array(0=>'未申请仲裁',1=>'待处理',2=>'已处理');?>
        <?php $c_arbitrate_status=array(0=>'未申请仲裁',1=>'待处理',2=>'已处理');?>
		<?php foreach ($list as $v):?>
		<tr data-id="<?php echo $v['nid'] ?>" data-sort="<?php echo $v['sort_id'] ?>">

            <?php if($this->cid==13 || $this->cid==14){?>
			<td><input class="select-it" type="checkbox" value="<?php echo $v['nid']; ?>" ></td>
            <?php }?>
            <td><?php echo $v['nid'] ?></td>
			<td> <?php echo $v['uname']; ?> </td>
            <?php if($this->cid==13){?>
			<td> <?php echo $v['title']; ?> </td>
			<td> <?php echo $v['margin']; ?> </td>
			<td> <?php if($v['claim_money'] > 0)echo $v['claim_money']; ?></td>
			<td> <?php if($v['update_money'] > 0)echo $v['update_money']; ?></td>
			<td> <?php echo $v['intro']; ?> </td>
            <td> <?php echo date("Y/m/d H:i:s",$v['created']); ?> </td>
			<td>
                <?php if($v['claim_nums'] > 0){?>
                <a href="<?php echo site_url('claim/index?c='.$this->cid.'&need_id='.$v['nid']) ?>"><?php echo $v['claim_nums']; ?></a>
                <?php }else{?>
                <?php echo $v['claim_nums']; ?>
                <?php }?>
            </td>
            <td> <?php if($v['countdown']!=0)echo date("Y/m/d H:i:s",$v['countdown']); ?> </td>
			<td> <?php echo $v['views']; ?> </td>
			<td> <?php echo $needs_status[$v['claim_status']]; ?> </td>
            <?php if($v['arbitrate']==1){?>
			<td class="arbitrate" data-id="<?php echo $v['nid']; ?>" data-money="<?php echo $v['claim_money']; ?>">
                <span class="btn btn-small agree" data-toggle="modal" data-id="<?php echo $v['id'];?>" style="background-color: cornflowerblue"><?php echo $arbitrate_status[$v['arbitrate']]; ?></span>
            </td>
            <?php }else{?>
            <td><?php echo $arbitrate_status[$v['arbitrate']]; ?></td>
            <?php }?>
            <?php if($v['c_arbitrate']==1){?>
                <td class="c_arbitrate" data-id="<?php echo $v['nid']; ?>">
                    <span class="btn btn-small agree" data-toggle="modal" data-id="<?php echo $v['id'];?>" style="background-color: cornflowerblue"><?php echo $c_arbitrate_status[$v['c_arbitrate']]; ?></span>
                </td>
            <?php }else{?>
                <td><?php echo $arbitrate_status[$v['c_arbitrate']]; ?></td>
            <?php }?>
            <?php }elseif($this->cid==14){?>
            <td> <?php echo $v['title']; ?> </td>
            <td> <?php echo $v['intro']; ?> </td>
            <td> <?php echo date("Y/m/d H:i:s",$v['created']); ?> </td>
            <td> <?php echo date("Y/m/d H:i:s",$v['end_time']); ?> </td>
            <td>
                <?php if($v['claim_nums'] > 0){?>
                    <a href="<?php echo site_url('claim/index?c='.$this->cid.'&need_id='.$v['nid']) ?>"><?php echo $v['claim_nums']; ?></a>
                <?php }else{?>
                    <?php echo $v['claim_nums']; ?>
                <?php }?>
            </td>
            <td> <?php echo $v['views']; ?> </td>
            <?php }elseif($this->cid==15){?>
            <td> <?php echo $v['title']; ?> </td>
            <td> <?php echo $v['intro']; ?> </td>
            <td> <?php echo date("Y/m/d H:i:s",$v['created']); ?> </td>
            <?php }?>
			<td>
				<div class="btn-group">
					<a class='btn btn-danger btn-small btn-del' data-id="<?php echo $v['nid'] ?>" href="#"  title="<?php echo lang('del') ?>"> <i class="fa fa-times"></i></a>
				</div>
			</td>
		</tr>
		<?php endforeach;?>
	</tbody>
</table>

	</div>
</div>

<!--输入弹窗-->
<div class="tab-float-box n1">
    <div class="box">
        <div class="cont">
            <div class="rows f-cb">
                <div class="tit">议价价格</div>
                <input type="text" name="claim_money" value="" class="in claim_money" readonly/>
                <div class="tit">修改价格</div>
                <input type="number" name="change_money" placeholder="请输入修改金额" class="in change_money"/>
            </div>
        </div>
        <div class="btn-box">
            <a href="javascript:;" class="enter">确定</a>
            <a href="javascript:;" class="res">取消</a>
        </div>
    </div>
</div>

<!--评分-->
<div class="tab-float-box n2">
    <div class="box" style="height: 95px;">
        <div class="cont">
            <div class="rows f-cb">
                <div class="tit">请选择评星</div>
                <select name="stars" id="stars">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                </select>
            </div>
        </div>
        <div class="btn-box">
            <a href="javascript:;" class="enter">确定</a>
            <a href="javascript:;" class="res">取消</a>
        </div>
    </div>
</div>
<?php if($this->cid==13 || $this->cid==14){?>
<div class="btn-group">
	<a id='select-all' class='btn' href="#"> <i class=""></i> <?php echo lang('select_all') ?> </a>
	<a id='unselect-all' class='btn hide' href="#"> <i class=""></i> <?php echo lang('unselect') ?> </a>
	<a id="btn-del" class='btn btn-danger' href="#"> <i class="fa fa-times"></i> <?php echo lang('del') ?> </a>
</div>
<?php }?>

<?php echo $pages; ?>

<script>
require(['adminer/js/ui'],function(ui){
	var needs = {
		url_del: "<?php echo site_urlc('needs/delete'); ?>"
	};
	ui.fancybox_img();
	ui.btn_delete(needs.url_del);		    // 删除

    //打开
    $(".arbitrate>span").on("click",function(){
        var c_money = $(this).parent().attr('data-money');
        var need_id = $(this).parent().data('id');
        $('.claim_money').val(c_money);
        $('.tab-float-box.n1').fadeIn(200).attr('data-id',need_id);
    });
    //确定
    $(".tab-float-box.n1 .enter").on("click",function(){
        var change_money = $('.change_money').val();
        var claim_money = $('.claim_money').val();
        var need_id = $('.tab-float-box.n1').attr('data-id');
        if(change_money==''){
            $.pnotify({
                title:"提示！",
                text:'请填写修改后的价格',
                type:"failed",
                animation: 'fade'
            });
            return;
        }
        if(parseInt(change_money) < 0){
            $.pnotify({
                title:"提示！",
                text:'请填写正确的价格',
                type:"failed",
                animation: 'fade'
            });
            return;
        }

        if(parseInt(change_money) > claim_money){
            $.pnotify({
                title:"提示！",
                text:'修改后的价格不可大于议价价格',
                type:"failed",
                animation: 'fade'
            });
            return;
        }
        var url='<?php echo site_url('need_ajax/arbitrate');?>';
        $.ajax({
            url:url,
            type:'post',
            dataType:'json',
            data:{change_money:change_money,need_id:need_id,_cfs:$.cookie('_cfc')}
        })
            .done(function(data){
                if(data.status){
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"success",
                        animation: 'fade'
                    });
                    setTimeout(function(){
                        $('.tab-float-box.n1').fadeOut(200);
                        window.location.reload();
                    }, 2000)
                }else{
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"failed",
                        animation: 'fade'
                    });
                }
            });
    });
    $(".tab-float-box.n1 .res").on("click",function(){
        $('.change_money').val('');
        $('.tab-float-box.n1').fadeOut(200);
    });

    $(".c_arbitrate>span").on("click",function(){
        var need_id = $(this).parent().data('id');
        $('.tab-float-box.n2').fadeIn(200).attr('data-id',need_id);
    });
    $(".tab-float-box.n2 .enter").on("click",function(){
        var need_id = $('.tab-float-box.n2').attr('data-id');
        var stars = $('#stars option:selected').val();
        var url='<?php echo site_url('need_ajax/c_arbitrate');?>';
        $.ajax({
            url:url,
            type:'post',
            dataType:'json',
            data:{stars:stars,need_id:need_id,_cfs:$.cookie('_cfc')}
        })
            .done(function(data){
                if(data.status){
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"success",
                        animation: 'fade'
                    });
                    setTimeout(function(){
                        $('.tab-float-box.n2').fadeOut(200);
                        window.location.reload();
                    }, 2000)
                }else{
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"failed",
                        animation: 'fade'
                    });
                }
            });
    });
    $(".tab-float-box.n2 .res").on("click",function(){
        $('.tab-float-box.n2').fadeOut(200);
    });
});
</script>
